package cn.csxw.openchina.ui.fragment.exerciseFragment;


import android.os.Bundle;
import android.support.annotation.Nullable;

import java.util.ArrayList;

import javax.inject.Inject;

import cn.csxw.openchina.base.BaseRecAdapter;
import cn.csxw.openchina.base.BaseRefreshFragment;
import cn.csxw.openchina.constant.Constant;
import cn.csxw.openchina.dagger2.component.DaggerRecentlyFragmentComponent;
import cn.csxw.openchina.dagger2.module.RecentlyFragmentModules;
import cn.csxw.openchina.dagger2.presenter.RecentlyFragmentPresenter;
import cn.csxw.openchina.entity.bean.EventBean;
import cn.csxw.openchina.ui.adapter.RecentlyAdapter;
import cn.csxw.openchina.utils.Global;

/**
 * 近期活动界面
 */

public class RecentlyExerciseFragment extends BaseRefreshFragment {
    private int pageIndex = 0;
    public RecentlyAdapter mRecentlyAdapter;
    @Inject
    RecentlyFragmentPresenter mFragmentPresenter;
    private String mUserUid = "-1";

    @Override
    protected BaseRecAdapter getAdapter() {
        if (mRecentlyAdapter == null) {
            mRecentlyAdapter = new RecentlyAdapter();
        }
        return mRecentlyAdapter;
    }

    @Override
    public void doRefresh() {
        mFragmentPresenter.callNetWork(mUserUid, 0, 20);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setOnRefreshListener(onRefreshListener);
        DaggerRecentlyFragmentComponent.builder().recentlyFragmentModules(new
                RecentlyFragmentModules(this)).build().inject(this);
        mFragmentPresenter.callNetWork(mUserUid, 0, 20);
        Global.onNetworkStateListener(mFragmentPresenter, this);
    }

    OnRefreshListener onRefreshListener = new OnRefreshListener() {
        @Override
        public void onUpLoadMore() {

      /*      mFragmentPresenter.callNetWork(mUserUid, 0, 20);*/
            noMoreData();
        }
    };
}
